package com.vegetable.modules.entity.outbound.excel;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.vegetable.common.base.BaseEntity;
import com.vegetable.modules.entity.finance.FinancialCollectionDetail;
import com.vegetable.modules.entity.inbound.OrderCost;
import com.vegetable.modules.entity.outbound.SalesOutCarryOn;
import com.vegetable.modules.entity.outbound.SalesOutDetail;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 销售出库单
 * </p>
 *
 * @author wangruijie
 * @since 2024-04-01
 */
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="SalesOut对象", description="销售出库单")
public class SalesOutExport extends BaseEntity {

    @Excel(name = "单据编号")
    private String docNo;

    @Excel(name = "订单日期")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd")
    private Date orderTime;

    @Excel(name = "商户名称")
    private String customerName;

    @Excel(name = "台账标识 0寿光 1河北")
    private Integer regionId;

    @Excel(name = "批次号")
    private String lotNo;

    @Excel(name = "数量")
    private Integer number;

    @Excel(name = "重量")
    private BigDecimal weight;

    @Excel(name = "销售金额")
    private BigDecimal money;

    @Excel(name = "利润")
    @TableField(exist = false)
    private BigDecimal totalProfit;



    // 使用集合存储动态列数据
    @ExcelCollection(name = "动态信息", orderNum = "2")
    private List<DynamicColumn> dynamicColumns = new ArrayList<>();

    public BigDecimal getMoney() {
        return money != null ? money.setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO;
    }

    // 添加动态列
    public void addDynamicColumn(String key, BigDecimal value) {
        this.dynamicColumns.add(new DynamicColumn(key, value));
    }


}
